package com.github.elliot.usercenter.controller;

import com.github.elliot.usercenter.po.Permission;
import com.github.elliot.usercenter.service.PermissionService;
import com.github.elliot.usercenter.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

    @Autowired
    private RoleService roleService;

    @GetMapping("/api/v1/permissions/{userNo}")
    public Flux<Permission> getPermission(@PathVariable("userNo") String userNo){
        return permissionService.findPermissionListByUserNo(userNo);
    }

    @GetMapping("/api/v1/permissions/by-user-no/{userNo}")
    public Flux<Permission> getPermissionUrlByUserNo(@PathVariable("userNo") String userNo){
        return roleService.getBackendUrlByUserNo(userNo);
    }
}
